package servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import remoto.BD;
import remoto.UnidadDTO;

public class ListaUnidadesServlet extends HttpServlet {

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
	
		resp.setContentType("text/html");
	    PrintWriter out = resp.getWriter();
	    out.println("<h2>Cabeceras</h2>");
	    List<UnidadDTO> lista = BD.getInstance().getGestion().getListaUnidades();
	    
	    out.println("<html>");
		out.println("<body>");
	    out.print("<table>");
	    for (UnidadDTO u : lista) {
	      out.print("<td>" + u.codigo + ":" + u.descripcion +"</td>: ");
	    }
	    out.print("</table>");
		out.println("</body>");
		out.println("</html>");	
	}

}
